<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
  <meta charset="UTF-8">
  <title>员工绩效的编辑</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
  <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
  <link rel="stylesheet" th:href="@{/css/font.css}">
  <link rel="stylesheet" th:href="@{/css/xadmin.css}">
  <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
  <script th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
  <script type="text/javascript" th:src="@{/js/xadmin.js}"></script>
  <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
  <!--[if lt IE 9]>
  <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
  <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
  <![endif]-->

  <style>
    .layui-form-item .layui-input-inline{
      width: 300px;
    }
  </style>
</head>

<body>
<div class="x-body">
  <form class="layui-form">
    <input type="hidden" name="performanceId" th:value="${param.id}">
    <div class="layui-form-item">
      <label class="layui-form-label">
        姓名
      </label>
      <div class="layui-input-inline">
        <input type="text" name="emplName" disabled
               autocomplete="off" class="layui-input">
      </div>
      <div class="layui-form-mid layui-word-aux">

      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">
        <span class="x-red">*</span>绩效等级
      </label>
      <div class="layui-input-inline">
        <input type="number" name="perLevel" required="" lay-verify="required"
               autocomplete="off" class="layui-input">
      </div>
      <div class="layui-form-mid layui-word-aux">

      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label">
      </label>
      <button  class="layui-btn" lay-filter="add" lay-submit="">
        编辑
      </button>
    </div>
  </form>
</div>
<script>
  layui.use(['form','layer'], function(){
    $ = layui.jquery;
    var form = layui.form
            ,layer = layui.layer;

    //监听提交
    form.on('submit(add)', function(data){
      var param = data.field;
      $.ajax({
        type: "post",// http请求方法
        url:"/sale/performance/edit",// 后端的接口
        contentType: 'application/json',
        data: JSON.stringify(param),// 传递到后端的数据
        dataType: "json", // 后端返回的数据类型
        success: function (res) {// 服务器成功响应之后对应的逻辑
          if (res.code === 200){
            layer.alert(res.msg, {icon: 6},function () {
              // 重载表格
              parent.tableIns.reload();
              // 获得frame索引
              var index = parent.layer.getFrameIndex(window.name);
              //关闭当前frame
              parent.layer.close(index);
            });
          }
        }
      });

      return false;
    });

    // 获取员工数据
    $.ajax({
      type: "post",// http请求方法
      url:"/sale/performance/detail/",// 后端的接口
      data:{performanceId: $("input[name=performanceId]").val()},
      dataType: "json", // 后端返回的数据类型
      async: false, // 异步转同步
      success: function (res) {// 服务器成功响应之后对应的逻辑

        console.log(res);
        if (res.code === 200){
          var data = res.data;
          // 做数据回显
          $("input[name=emplName]").val(data.empl.emplName);
          // 回显性别/状态
          // 回显部门数据
          $("input[name=perLevel]").val(data.perLevel);
          form.render();
        }
      }
    });
  });
</script>

</body>

</html>
